package com.ningxun.pagentcrawler.entity.policy;

import java.time.LocalDateTime;

/**
 * 政策条目实体类
 * 用于存储爬取到的政策数据
 */
public class PolicyItem {
    private String title;    // 政策标题
    private String url;      // 政策链接
    private String content;  // 政策正文HTML内容
    private String documentNumber;  // 文号
    private String issueDate;       // 发布日期
    
    // 爬虫相关字段
    private String source;        // 数据来源 (如: "河北省政府", "北京市政府")
    private String crawlerConfig; // 爬虫配置名称
    private String taskId;        // 爬虫任务ID
    private LocalDateTime crawlTime; // 爬取时间
    private String status;        // 数据状态 (如: "已爬取", "已审核")
    
    // 默认构造函数
    public PolicyItem() {}
    
    // 带参构造函数
    public PolicyItem(String title, String url, String content) {
        this.title = title;
        this.url = url;
        this.content = content;
    }
    
    // Getter和Setter方法
    public String getTitle() { 
        return title; 
    }
    
    public void setTitle(String title) { 
        this.title = title; 
    }
    
    public String getUrl() { 
        return url; 
    }
    
    public void setUrl(String url) { 
        this.url = url; 
    }
    
    public String getContent() { 
        return content; 
    }
    
    public void setContent(String content) { 
        this.content = content; 
    }
    
    public String getDocumentNumber() {
        return documentNumber;
    }
    
    public void setDocumentNumber(String documentNumber) {
        this.documentNumber = documentNumber;
    }
    
    public String getIssueDate() {
        return issueDate;
    }
    
    public void setIssueDate(String issueDate) {
        this.issueDate = issueDate;
    }
    
    // 爬虫相关字段的Getter和Setter
    public String getSource() {
        return source;
    }
    
    public void setSource(String source) {
        this.source = source;
    }
    
    public String getCrawlerConfig() {
        return crawlerConfig;
    }
    
    public void setCrawlerConfig(String crawlerConfig) {
        this.crawlerConfig = crawlerConfig;
    }
    
    public String getTaskId() {
        return taskId;
    }
    
    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }
    
    public LocalDateTime getCrawlTime() {
        return crawlTime;
    }
    
    public void setCrawlTime(LocalDateTime crawlTime) {
        this.crawlTime = crawlTime;
    }
    
    public String getStatus() {
        return status;
    }
    
    public void setStatus(String status) {
        this.status = status;
    }
    
    @Override
    public String toString() {
        return "标题: " + title + 
               ", 链接: " + url + 
               ", 文号: " + (documentNumber != null ? documentNumber : "无") +
               ", 发布日期: " + (issueDate != null ? issueDate : "无") +
               ", 内容长度: " + (content != null ? content.length() : 0) + " 字符";
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        PolicyItem that = (PolicyItem) obj;
        return url != null ? url.equals(that.url) : that.url == null;
    }
    
    @Override
    public int hashCode() {
        return url != null ? url.hashCode() : 0;
    }
} 